//index.js
//获取地图
const app = getApp()
var map= [
  
  {
    "fId":"1",
    "name": "游乐项目",
    "scale": 15,
    "latitude": 39.854,
    "longitude": 116.6838,
    "iconPath":"/projects/TRIP1/images/tabbar/游乐.png",
    "data": [
      {
        "name": "未来水世界",
        id:0,
        "latitude": "39.85895",
        "longitude": "116.68563",
        "iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"未来水世界",
          bgColor:"#caf0f8",
          color:"#000000",
          fontSize: 17,
          borderRadius:30,
          display:"ALWAYS"},
        "img": [
          "https://www.universalbeijingresort.com/sites/default/files/2021-09/WaterWorld%20Stunt%20Show1.jpg",
          "https://www.universalbeijingresort.com/sites/default/files/2021-09/WaterWorld%20Stunt%20Show3.jpg"
        ],
        "description": "在未来水世界，你将观看一场环球影城首屈一指的水上爆破特技表演！从水上摩托艇极速俯冲的惊险特技，到飞机触目惊心的坠毁现场，你将零距离感受扣人心弦的生死搏斗带来的逼真体验。",
        "score": "10/10",
        "perperson": "110元/人",
        "keyword": "扣人心弦的生死对战！",
        "stream": "89"
      },
      {
        "name": "神龙大侠之旅",
        id: 1,
        "latitude": "39.8591",
        "longitude": "116.68302",
        "iconPath": "../../images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"神龙大侠之旅",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
			"../../images/home/b3.jpg",
			"../../images/home/b5.jpg"
		],
          "description": "神龙大侠之旅"
        },
      {
        "name": "灯影传奇",
        id: 2,
        "latitude": "39.85858",
        "longitude": "116.68426",
        "iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"灯影传奇",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
			"../../images/home/b3.jpg",
			"../../images/home/b5.jpg"
		],
          "description": "灯影传奇"
        },
      {
        "name": "大黄蜂回旋机",
        id: 3,
        "latitude": "39.85803",
        "longitude": "116.68087",
        "iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"大黄蜂回旋机",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "侏罗世纪大冒险",
        id: 4,
        "latitude": "39.85671",
        "longitude": "116.68346",
        "iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"侏罗世纪大冒险",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
			"../../images/home/b3.jpg",
			"../../images/home/b5.jpg"
          ],
          "description": ""
        },
    
      {
        "name": "奇遇迅猛龙",
        id: 5,
        "latitude": "39.85624",
        "longitude": "116.68379",
        "iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"奇遇迅猛龙",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
		},
		{
			"name": "鹰马飞行",
			id: 6,
			"latitude": "39.85641",
			"longitude": "116.68705",
			"iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
			"width": "30",
			"height": "30",
			callout: {padding:2,
			  content:"鹰马飞行",
			  bgColor:"#FFFFFf",
			  color:"#000000",
			  fontSize: 12,
			  borderRadius:30,
			  display:"ALWAYS"},
			  "img": [
				"../../images/home/b3.jpg",
				"../../images/home/b5.jpg"
			  ],
			  "description": ""
			},
			{
				"name": "好莱坞",
				id: 7,
				"latitude": "39.85497",
				"longitude": "116.67978",
				"iconPath": "/projects/TRIP1/images/tabbar/游乐.png",
				"width": "30",
				"height": "30",
				callout: {padding:2,
				  content:"好莱坞",
				  bgColor:"#FFFFFf",
				  color:"#000000",
				  fontSize: 12,
				  borderRadius:30,
				  display:"ALWAYS"},
				  "img": [
					"../../images/home/b3.jpg",
					"../../images/home/b5.jpg"
				  ],
				  "description": ""
				},
    ]
  },
  {
    "fId":"2",
    "name": "演出表演",
    "scale": 15,
    "latitude": 39.854,
    "longitude": 116.6838,
    "iconPath":"/img/bj.png",
    "data": [
      {
        "name": "欢乐好声音巡演",
        id: 0,
        "floor": "欢乐好声音巡演",
        "latitude": "39.8545",
        "longitude": "116.68497",
        "iconPath": "/projects/TRIP1/images/tabbar/演出.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"欢乐好声音巡演",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
			"../../images/home/b3.jpg",
			"../../images/home/b5.jpg"
          ],
          "description": ""
        },
      {
        "name": "王者荣耀英雄见面会",
        id: 1,
        "floor": "王者荣耀英雄见面会",
        "latitude": "39.85525",
        "longitude": "116.68068",
        "iconPath": "/projects/TRIP1/images/tabbar/演出.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"王者荣耀英雄见面会",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "霍格沃茨城堡夜间魔法庆典",
        id: 2,
        "latitude": "39.85668",
        "longitude": "116.68691",
        "iconPath": "/projects/TRIP1/images/tabbar/演出.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"霍格沃茨城堡夜间魔法庆典",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
        {
        "name": "变形金刚：传奇现场",
        id: 2,
        "latitude": "39.85805",
        "longitude": "116.68085",
        "iconPath": "/projects/TRIP1/images/tabbar/演出.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"变形金刚：传奇现场",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
        {
          "name": "小黄人快闪",
          id: 2,
          "latitude": "39.85106",
          "longitude": "116.6772",
          "iconPath": "/projects/TRIP1/images/tabbar/演出.png",
          "width": "30",
          "height": "30",
          callout: {padding:2,
            content:"小黄人快闪",
            bgColor:"#FFFFFf",
            color:"#000000",
            fontSize: 12,
            borderRadius:30,
            display:"ALWAYS"},
            "img": [
              ""
            ],
            "description": ""
          },
    ]
  },
  {
    "fId":"3",
    "name": "洗手间",
    "scale": 15,
    "latitude": 39.854,
    "longitude": 116.6838,
    "iconPath":"/img/bj.png",
    "data": [
      {
        "name": "洗手间",
        id: 0,
        "latitude": "39.85192",
        "longitude": "116.67663",
        "iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"洗手间",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "洗手间",
        id: 1,
        "latitude": "39.84996",
        "longitude": "116.6768",
        "iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"洗手间",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "洗手间",
        id: 2,
        "latitude": "39.84845",
        "longitude": "116.67732",
        "iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"洗手间",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "洗手间",
        id: 3,
        "latitude": "39.85448",
        "longitude": "116.6783",
        "iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"洗手间",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "洗手间",
        id: 4,
        "latitude": "39.85577",
        "longitude": "116.68103",
        "iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"洗手间",
          bgColor:"#FFFFFf",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
		},
		{
			"name": "洗手间",
			id: 5,
			"latitude": "39.85693",
			"longitude": "116.68616",
			"iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
			"width": "30",
			"height": "30",
			callout: {padding:2,
			  content:"洗手间",
			  bgColor:"#FFFFFf",
			  color:"#000000",
			  fontSize: 12,
			  borderRadius:30,
			  display:"ALWAYS"},
			  "img": [
				""
			  ],
			  "description": ""
			},
			{
				"name": "洗手间",
				id: 6,
				"latitude": "39.85425",
				"longitude": "116.68285",
				"iconPath": "/projects/TRIP1/images/tabbar/洗手间.png",
				"width": "30",
				"height": "30",
				callout: {padding:2,
				  content:"洗手间",
				  bgColor:"#FFFFFf",
				  color:"#000000",
				  fontSize: 12,
				  borderRadius:30,
				  display:"ALWAYS"},
				  "img": [
					""
				  ],
				  "description": ""
				},
    ]
  },
  {
    "fId":"4",
    "name": "文创商店",
    "scale": 15,
    "latitude": 39.854,
    "longitude": 116.6838,
    "iconPath":"/img/bj.png",
    "data": [
      {
        "name": "费尔奇没收店商店",
        id: 0,
        "latitude": "39.85732",
        "longitude": "116.6876",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"费尔奇没收店商店",
          bgColor:"#1297DB",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "侏罗纪集市",
        id: 1,
        "latitude": "39.85668",
        "longitude": "116.68339",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"侏罗纪集市",
          bgColor:"#1297DB",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "平先生神龙大侠大百货",
        id: 2,
        "latitude": "39.85918",
        "longitude": "116.68337",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"平先生神龙大侠大百货",
          bgColor:"#F19EC2",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "特种工装备店",
        id: 3,
        "latitude": "39.85887",
        "longitude": "116.68026",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"特种工装备店",
          bgColor:"#1297DB",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "环球影城商店",
        id: 4,
        "latitude": "39.85534",
        "longitude": "116.67995",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"环球影城商店",
          bgColor:"#1297DB",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "泡泡玛特全球概念店",
        id: 5,
        "latitude": "39.85015",
        "longitude": "116.6773",
        "iconPath": "/projects/TRIP1/images/tabbar/商店.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"泡泡玛特全球概念店",
          bgColor:"#1297DB",
          color:"#fff",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      
    ]
  },
  {
    "fId":"5",
    "name": "美食餐厅",
    "scale": 15,
    "latitude": 39.854,
    "longitude": 116.6838,
    "iconPath":"/img/bj.png",
    "data": [
      {
        "name": "背离的秘密餐吧",
        "latitude": "39.85798",
        "longitude": "116.68143",
        "iconPath": "/projects/TRIP1/images/tabbar/餐厅.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"背离的秘密餐吧",
          bgColor:"#FFFFFF",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "落霞餐厅",
        "latitude": "39.85635",
        "longitude": "116.68089",
        "iconPath": "/projects/TRIP1/images/tabbar/餐厅.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"落霞餐厅",
          bgColor:"#FFFFFF",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
        "img": [
          "校园导览/南苑男生/南苑1栋.jpg"
        ],
        "description": "落霞餐厅",
      },
      {
        "name": "红龙酒廊",
        "latitude": "39.85384",
        "longitude": "116.6792",
        "iconPath": "/projects/TRIP1/images/tabbar/餐厅.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"红龙酒廊",
          bgColor:"#FFFFFF",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "珍宝海鲜餐厅",
       "latitude": "39.84993",
    	"longitude": "116.67749",
        "iconPath": "/projects/TRIP1/images/tabbar/餐厅.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"珍宝海鲜餐厅",
          bgColor:"#FFFFFF",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
      {
        "name": "禾家中餐厅",
        "latitude": "39.85093",
        "longitude": "116.68237",
        "iconPath": "/projects/TRIP1/images/tabbar/餐厅.png",
        "width": "30",
        "height": "30",
        callout: {padding:2,
          content:"禾家中餐厅",
          bgColor:"#FFFFFF",
          color:"#000000",
          fontSize: 12,
          borderRadius:30,
          display:"ALWAYS"},
          "img": [
            ""
          ],
          "description": ""
        },
  ]}
   
]





Page({
  data: {
    //云开发数据
      avatarUrl: './user-unlogin.png',
      userInfo: {},
      logged: false,
      takeSession: false,
      requestResult: '',

    latitude: 39.854,
    longitude: 116.6838,
    scale:"15",
    buildlData: map,
    isSelectedBuild:0,
    isSelectedBuildType: 0,
    islocation: true,
    focusPointId:"",
    isChecked:true ,
    currentItemId:"1"
    
  },
  //获取用户信息
  onLoad: function() {
    if (!wx.cloud) {
      wx.redirectTo({
        url: '../chooseLib/chooseLib',
      })
      return
    }
    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
          wx.getUserInfo({
            success: res => {
              this.setData({
                avatarUrl: res.userInfo.avatarUrl,
                userInfo: res.userInfo
              })
            }
          })
        }
        else{
          wx.navigateTo({
            url: '/pages/grant/grant',
          })
        }
      }
    })
  },
  onGetUserInfo: function(e) {
    if (!this.data.logged && e.detail.userInfo) {
      this.setData({
        logged: true,
        avatarUrl: e.detail.userInfo.avatarUrl,
        userInfo: e.detail.userInfo
      })
    }
  },
//调用云函数
  onGetOpenid: function() {
    // 调用云函数
    wx.cloud.callFunction({
      name: 'login',
      data: {},
      success: res => {
        console.log('[云函数] [login] user openid: ', res.result.openid)
        app.globalData.openid = res.result.openid
       
      },
      fail: err => {
        console.error('[云函数] [login] 调用失败', err)
       
      }
    })
  },
//定位
  
getCenterLocation: function () {
  wx.getLocation({
    type: "gcj02",
    success: (res) => {
      this.setData({
        longitude: res.longitude,
        scale:450,
        latitude: res.latitude,
      });
      console.log(
        "当前中心点的位置：",
        this.data.longitude,
        this.data.latitude
      );
    },
    fail: (err) => {
      wx.showToast({
        title: "GPS定位失败",
        icon: "fail",
      });
      console.log("err", err);
    },
  });
},
//展示标志点
  changePage: function (event) {
    
    this.setData({
      currentItemId:event.currentTarget.dataset.num,
      isSelectedBuildType: event.currentTarget.dataset.num-1,
      longitude:map[event.currentTarget.dataset.num-1].longitude,
      latitude:map[event.currentTarget.dataset.num-1].latitude,
      scale: 16,
    });
    
  },
//标记跳转
  markertap(res) {
   
  
    var mark=res.currentTarget.dataset.num;
    var markerId=res.detail.markerId;
    
    let temp=JSON.stringify(mark[markerId])//作用是把数组转变成可以在网页传递中的参数进行传递

        wx.navigateTo({
          url: "../../pages/info/info?mar="+temp,
        })
    },
//聊天室跳转
  navitap:function(){
  
       wx.navigateTo({
      url: '/pages/chat/chat',
       })
      },

//路线规划跳转
selectPoint:function(){
  
  wx.navigateTo({
 url: '/projects/TRIP1/pages/selectPoint/selectPoint',
  })
 },
    /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '我共享了我的位置，快来找我一起游玩吧！',
      path: '/pages/map/map',
      imageUrl: "/image/swiper-3.jpeg"
    }
  },
  /**
   * 用户分享到朋友圈
   */
  onShareTimeline: function () {
    return {
      title: '我在' + config.appName + '共享了我的位置，快来找我一起吧！',
      path: '/pages/map/map',
      imageUrl: "/image/swiper-3.jpeg"
    }
  },

  search: function () {
    wx.navigateTo({
      url: '../search/search',
    })
  },
})